package cn.snews.Servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.NewsDAO;

public class DelNewsServlet extends HttpServlet {

	private static final long serialVersionUID = 9214197293954890011L;

	public DelNewsServlet() {
		super();
	}

	public void destroy() {
		super.destroy();
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		Integer tid = Integer.parseInt(request.getParameter("nid"));
		int k = NewsDAO.DAO.del(tid);
		request.setAttribute("num", k);
		request.getRequestDispatcher("/WEB-INF/jsp/deltopic.jsp").forward(
				request, response);
	}

	public void init() throws ServletException {
	}

}
